package com.rising.threads.unsafeContainer;

import org.omg.CORBA.TIMEOUT;

import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;

/**
 * @Author: rising
 * @Description:
 * @Date: create in 2020/12/27 15:42
 */
public class ArrayListDemo {
    public static void main(String[] args) throws InterruptedException {
        //List<String> list = Collections.synchronizedList(new ArrayList<>());
        List<String> list = new CopyOnWriteArrayList<>();
        for (int i = 0; i < 30; i++) {
            new Thread(() -> {
                list.add(UUID.randomUUID().toString().substring(0,8));
                System.out.println(list);
            }, String.valueOf(i)).start();
        }
    }
}
